package com.example.gpay

import com.android.billingclient.api.Purchase

interface GPayHandle {
    /**
     * 校验订单，现在该接口去服务器校验订单，需同步执行
     * @param purchase 数据结构
     * {
     *   "orderId" : "GPA.3326-8614-7271-84706", //google订单id
     *   "packageName" : "com.xxx.xxx",
     *   "productId" : "product_id_1",
     *   "purchaseTime" : 1732593152647,
     *   "purchaseState" : 0,
     *   "purchaseToken" : "dlipnfhcgfpoklpgkoedfnfl.AO-J1OwkNh3NEi5GCG0bJ5fHRU9wSjb8mHUT_PsC3hwhU-gTnXKiFIuFVDYuq0Vund9qH0cXeHAm9AYIQ4ydvaU1tN3bjw1wxIergJweZjs-lyKzZEIK6M8",
     *   "obfuscatedAccountId" : "orderno_product_id_1", //服务器订单orderNo
     *   "quantity" : 1,
     *   "acknowledged" : false
     * }
     *
     * @return 返回校验的结果，true校验成功（自动进行消耗或者订阅的确认），false校验失败（不会消耗或订阅确认）
     */
    suspend fun onVerifyPurchase(purchase: Purchase): Boolean

    /**
     * 购买消耗成功（全局，只要有成功消耗的购买就回调）
     */
    fun onConsumeSuccess(purchase: Purchase)

    /**
     * 订阅确认成功（全局，只要有成功确认的订阅就回调）
     */
    fun onAcknowledgePurchaseSuccess(purchase: Purchase)

    fun logReviewOrder(log: String) {}
    fun logReviewOrderResp(log: String) {}
    fun logLaunchPay(log: String) {}
    fun logLaunchPayResp(log: String) {}

    /**
     * log 校验
     */
    fun logVerifyOrder(log: String) {}

    /**
     * log 校验响应
     */
    fun logVerifyOrderResp(log: String) {}

    /**
     * log 消耗
     */
    fun logConsumeOrder(log: String) {}


    /**
     * log 消耗响应
     */
    fun logConsumeOrderResp(log: String) {}

    /**
     * log 订阅确认
     */
    fun logAcknowledgedOrder(log: String) {}

    /**
     * log 订阅确认响应
     */
    fun logAcknowledgedOrderResp(log: String) {}

    /**
     * (补单) log 校验
     */
    fun logRestoreVerifyOrder(log: String) {}

    /**
     * (补单) log 校验响应
     */
    fun logRestoreVerifyOrderResp(log: String) {}

    /**
     * (补单) log 消耗
     */
    fun logRestoreConsumeOrder(log: String) {}


    /**
     * (补单) log 消耗响应
     */
    fun logRestoreConsumeOrderResp(log: String) {}

    /**
     * (补单) log 订阅确认
     */
    fun logRestoreAcknowledgedOrder(log: String) {}

    /**
     * (补单) log 订阅确认响应
     */
    fun logRestoreAcknowledgedOrderResp(log: String) {}
}